//
//  LVImpDynamicListVC.m
//  LEVE
//
//  Created by 上官惠阳 on 2017/2/27.
//  Copyright © 2017年 dashuju. All rights reserved.
//

#import "LVImpDynamicListVC.h"
#import "LVImpListCell.h"
#import "HYCustomCommonEmptyView.h"
#import "LVImpModel.h"
#import "LVShareModel.h"

@interface LVImpDynamicListVC ()
@property (nonatomic, weak) HYCustomCommonEmptyView *emptyView;
@end

@implementation LVImpDynamicListVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"周边动态";

    WeakSelf(weakSelf);
    [self HY_setUpNavLeftItemTitle:nil itemImage:@"return" handle:^(NSString *leftItemTitle) {
        [weakSelf dismissViewControllerAnimated:YES completion:nil];
    }];

    self.refreshType = HYBaseTableVcRefreshTypeRefreshAndLoadMore;

    [self loadData];

}
- (void)loadData
{
    for (int i = 1; i <= 5; i++) {
        LVImpModel *model = [[LVImpModel alloc] init];
        for (int j = 0; j < i; j ++) {
            LVShareModel *m = [[LVShareModel alloc] init];
            [model.shareModelArr addObject:m];
        }
        [self.dataArray addObject:model];
    }
    if (!self.dataArray.count) {
        [self.emptyView showInView:self.view];
    }else{
        [self.emptyView removeFromSuperview];
    }

    [self HY_reloadData];
}
#pragma mark refresh
- (void)HY_refresh
{
    [super HY_refresh];

    [self.dataArray removeAllObjects];
    [self loadData];

    [self HY_endRefresh];
}
- (void)HY_loadMore
{
    [super HY_loadMore];

    [self loadData];

    [self HY_endLoadMore];
}
#pragma mark - UITableViewDelegate
- (NSInteger)HY_numberOfSections {
    return 1;
}

- (NSInteger)HY_numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (HYBaseTableViewCell *)HY_cellAtIndexPath:(NSIndexPath *)indexPath {
    LVImpModel *model = self.dataArray[indexPath.row];
    LVImpListCell *cell = [LVImpListCell nibCellWithTableView:self.tableView];
    [cell loadCellWithModel:model];

    cell.seleteShareBlock = ^(LVShareModel *model){

    };
    return cell;
}

- (CGFloat)HY_cellheightAtIndexPath:(NSIndexPath *)indexPath {
    return 77;
}
#pragma mark emptyView
- (HYCustomCommonEmptyView *)emptyView {
    if (!_emptyView) {
        HYCustomCommonEmptyView *empty = [[HYCustomCommonEmptyView alloc] initWithTitle:@"暂无动态" secondTitle:@"" iconname:@"无动态"];
        [self.view addSubview:empty];
        _emptyView = empty;
    }
    return _emptyView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
